package com.hongpu.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hongpu.domain.InvoiceTaxRate;
import com.hongpu.mapper.InvoiceTaxRateMapper;
import com.hongpu.service.InvoiceTaxRateService;
import com.hongpu.vo.InvoiceTaxRateVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
* @author Michael zhang
* @description 针对表【invoice_tax_rate(发票税率表)】的数据库操作Service实现
* @createDate 2025-05-19 14:16:38
*/
@Service
public class InvoiceTaxRateServiceImpl extends ServiceImpl<InvoiceTaxRateMapper, InvoiceTaxRate>
    implements InvoiceTaxRateService{

    @Autowired
    InvoiceTaxRateMapper baseMapper;

    /**
     * 分页查询
     *
     * @param page
     * @param invoiceTaxRate
     * @return
     */
    @Override
    public IPage<InvoiceTaxRate> page(IPage<?> page, InvoiceTaxRate invoiceTaxRate) {
        return baseMapper.page(page, invoiceTaxRate);
    }

    /**
     * 下拉列表
     */
    @Override
    public List<InvoiceTaxRateVo> list4Select() {
        List<InvoiceTaxRate> list = list();
        if(CollectionUtils.isEmpty(list)){
            return null;
        }else {
            List<InvoiceTaxRateVo> result = new ArrayList<>();
            for (InvoiceTaxRate invoiceTaxRate : list) {
                InvoiceTaxRateVo invoiceTaxRateVo = new InvoiceTaxRateVo();
                BeanUtils.copyProperties(invoiceTaxRate, invoiceTaxRateVo);
                result.add(invoiceTaxRateVo);
            }
            return result;
        }
    }
}




